package com.pzh.assignment.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import java.io.Serializable;
import java.time.LocalDateTime;

import com.pzh.assignment.common.bean.param.ProgramParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

/**
 * <p>
 * 
 * </p>
 *
 * @author pengzhihao
 * @since 2022-04-16
 */
@Getter
@Setter
@ApiModel(value = "Program对象", description = "")
public class Program implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("培养方案id")
      @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @ApiModelProperty("外键：课程id")
    private Integer courseId;

    @ApiModelProperty("外键：年级id")
    private Integer gradeId;

    @ApiModelProperty("外键：专业id")
    private Integer majorId;

    @ApiModelProperty("实验学时")
    private Float experimental;

    @ApiModelProperty("理论学时")
    private Float theoretical;

    @ApiModelProperty("学分")
    private Float credit;

    @ApiModelProperty("是否完成分配： 0 否。1 是")
    private Integer status;

    @ApiModelProperty("考核方式：0 考察  1 考试")
    private Integer method;

    @ApiModelProperty("课程所对应的学期（1-8）")
    private Integer term;

      @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime;

      @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;

    @TableLogic
    private Integer deleted;


    public static Program valueOf(ProgramParam param) {
        Program program = new Program();
        program.setId(param.getId());
        program.setCourseId(param.getCourseId());
        program.setGradeId(param.getGradeId());
        program.setMajorId(param.getMajorId());
        program.setTheoretical(param.getTheoretical());
        program.setExperimental(param.getExperimental());
        program.setCredit(param.getCredit());
        program.setMethod(param.getMethod());
        program.setTerm(param.getTerm());
        program.setStatus(0);
        return program;
    }

}
